package de.unihannover.hci.portraitquiz;

import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Vibrator;
import android.view.Menu;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import android.widget.Toast;
import de.unihannover.hci.portraitquiz.adapter.ObstacleAdapter;
import de.unihannover.hci.portraitquiz.helper.ObstacleImageView;
import de.unihannover.hci.portraitquiz.helper.ShapeObstacle;
import de.unihannover.hci.portraitquiz.helper.ShapeObstacle.DIFFICULTY;

import de.unihannover.hci.portraitquiz.model.Answer;

public class ObstacleChooserActivity extends Activity {

	private PortraitQuiz app;
	/**
	 * reffers to the current question in the answers List;
	 */
	private int questionCount;
	private int wrongAnswers;
	private int points;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.activity_obstacle_chooser);

		GridView obstaclesView = (GridView) findViewById(R.id.chooseObstacle);
		if (!ShapeObstacle.isInitialized()) {
			ShapeObstacle.initialize(this);
		}
		app = (PortraitQuiz) getApplication();

		// Set fonts
		TextView title1 = (TextView) findViewById(R.id.title);
		TextView title2 = (TextView) findViewById(R.id.title2);
		Typeface type = app.getAppFontType();
		title1.setTypeface(type);
		title2.setTypeface(type);

		obstaclesView.setAdapter(new ObstacleAdapter(this, app));

		obstaclesView.setOnItemClickListener(

		new OnItemClickListener() {

			public void onItemClick(AdapterView<?> av, View view, int position, long id) {
				for (int i = 0; i < av.getChildCount(); i++) {
					if (i != position)
						av.getChildAt(i).setBackgroundColor(ObstacleAdapter.COLOR_DISABLED);
				}
				view.setBackgroundColor(ObstacleAdapter.COLOR_ENABLED);
				app.setObstacle(ShapeObstacle.getObstacle(position));
			};
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_obstacle_chooser, menu);
		return true;
	}

	@Override
	protected void onPause() {
		super.onPause();
	}
}
